<template>
    <button class="dj-button" :class="type" @click="clickHandle"><slot>primary</slot></button>
</template>
<script>
import emitter from '../mixins/emitter.js'
export default {
  name: 'dj-button',
  mixins: [emitter],
  props: {
    type: {
      type: String,
      default: 'primary',
      validator: text => {
        let typeArr = ['primary', 'default', 'submit']
        return typeArr.includes(text)
      }
    }
  },
  data () {
    return {

    }
  },
  methods: {
    clickHandle () {
      if (this.type === 'submit') this.dispatch('dj-form', 'form-submit')
      this.$emit('click')
    }
  }
}
</script>
<style lang="scss" scoped>
.dj-button{
    width: 100%;
    height: 40px;
    border: 0;
    background: #57a3f3;
    border-radius: 2px;
    color: #fff;
    font-size: 16px;
    outline: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    &.default{
      border: 1px solid #eee;
      background: #fff;
      color: #333;
    }
}
</style>
